package com.tbit.uqbike.webmanager.business.brandshare.pojo;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.FieldNameConstants;

import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 品牌共享配置
 *
 * @author: qiu.longjie
 * @create: 2025-05-19
 */
@Data
@FieldNameConstants
@TableName(value = "brand_share_config", autoResultMap = true)
public class BrandShareConfig {

    /**
     * id
     */
    @TableId(type = IdType.AUTO)
    private Integer id;
    /**
     * 配置名称
     */
    private String configName;
    /**
     * 创建时间
     */
    private Date createdTime;
    /**
     * 更新时间
     */
    private Date updatedTime;
    /**
     * 品牌id集合
     */
    @TableField(exist = false)
    private String brandIds;
    /**
     * 品牌名称集合
     */
    @TableField(exist = false)
    private String brandNames;

    @TableField(exist = false)
    private List<Integer> brandIdList;

    public List<Integer> getBrandIdList() {
        if (StrUtil.isNotEmpty(brandIds)) {
            return Arrays.stream(brandIds.split(",")).map(Integer::valueOf).collect(Collectors.toList());
        }
        return Collections.emptyList();
    }
}
